<?php
	require_once (dirname(__FILE__)."/../config/Config.inc");
	require_once (dirname(__FILE__)."/../config/api.inc");
	
	$parm = requestArrayParm($_REQUEST);
	
	$result['status'] = '1';
	
	unset($query);
	
	if(!empty($parm['ptlx']))
	{
		$query['pt_type'] = $parm['ptlx'];
	}
	
	if(!empty($parm['ptbj']))
	{
		$query['pt_bj'] = $parm['ptbj'];
	}
	
	unset($where);
	
	if(!empty($query))
	{
		$resData = _SqlTool::getList('pingtai', $query);
	
		if(empty($resData))
		{
			$result['cplist'] = array();
			echoJSON($result);
		}
		else
		{
			unset($ptids);
			foreach($resData as $k => $v)
			{
				$ptids[] = $v['id'];
			}
		}
		
	}
	
	
	$wheres['cp_status'] = '2';
	
	if(!empty($ptids))
	{
		$wheres['pt_id'] = array('in',join(',', $ptids));
	}
	
	if(!empty($parm['lc_type']))
	{
		$wheres['lc_type'] = $parm['lc_type'];
	}
	
	$resData = _SqlTool::getList('chanpin', $wheres);
	
	foreach ($resData as $k => $v)
	{
		unset($query);
		$query['id'] = $v['pt_id'];
		$pingtai = _SqlTool::getInfo('pingtai', $query);
				
		unset($temp);
		$temp['id'] = $v['id'];
		$temp['logo'] = OSS_URL.$pingtai['pt_logo'];
		$temp['name'] = $v['cp_mc'];
		$temp['style'] = $CP_FS[$v['cp_style']];
		
		$temp['lctype'] = $lcType[$v['lc_type']];
		
		$temp['yqnh'] = $v['cp_yqnh'];
		if($v['cp_type'] == '1')
		{
			unset($query);
			$query['cp_id'] = $v['id'];
			$temp['zgfl'] = _SqlTool::getMax('cp_gdfa', $query, $between, 'fanli');
		}
		if($v['cp_type'] == '2')
		{
			$temp['zgfl'] = $v['cp_fl'];
		}
		
		$temp['qixian'] = $v['cp_tzqx'];
		$temp['qixianlx'] = $v['cp_tzqxlx'];
		
		
		$temp['qtje'] = $v['cp_qtje'];
		$temp['url'] = SITE_URL."skip.php?id=".$v['id'].'&loginkey='.$parm['loginkey'];
		$temp['type'] = $v['cp_type'];
		$temp['cp_lxxs'] = $v['cp_lxxs'];
		$temp['is_new'] = $v['is_new'];
		$list[] = $temp;
		$result['cplist'][] = $temp;
	}
	
	echoJSON($result);